package array

func UnionWith(arrays ...[]T) []T {
	// todo
	var ret []T
	for _, array := range arrays {
		for _, value := range array {
			var cross = true
		label:
			for _, otherArr := range arrays {
				if idx := IndexOf(otherArr, value); idx < 0 {
					cross = false
					break label
				}
			}
			if cross {
				ret = append(ret, value)
			}
		}
	}
	return ret
}